﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DevelopAssistant.Core.ToolBox
{
    public partial class SelectSkinPad : ToolBoxBase 
    {
        public string ThemeName { get; set; }

        public SelectSkinPad()
        {
            InitializeComponent();
        }

        public SelectSkinPad(ICSharpCode.WinFormsUI.Theme.WinFormsUIThemeBase theme)
            : this()
        {
            this.XTheme = theme;

            themeWindows.Text = "Windows";
            themeApple.Text = "Apple";
            themeBootstrip.Text = "Bootstrip";
            themeMore.Text = "More";

            if (this.XTheme.GetType().Equals(typeof(ICSharpCode.WinFormsUI.Theme.ThemeVS2012)))
            {
                themeWindows.Checked = true;             
            }
            else if (this.XTheme.GetType().Equals(typeof(ICSharpCode.WinFormsUI.Theme.ThemeMac)))
            {
                themeApple.Checked = true;               
            }
            else if (this.XTheme.GetType().Equals(typeof(ICSharpCode.WinFormsUI.Theme.ThemeShadow)))
            {
                themeBootstrip.Checked = true;               
            }

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnApply_Click(object sender, EventArgs e)
        {
            string checkedThemeName = string.Empty;
            foreach (var theme in this.groupBox1.Controls)
            {
                if (theme.GetType().Equals(typeof(ICSharpCode.WinFormsUI.Controls.NTheme)))
                {
                    if (((ICSharpCode.WinFormsUI.Controls.NTheme)(theme)).Checked)
                    {
                        checkedThemeName = ((ICSharpCode.WinFormsUI.Controls.NTheme)(theme)).Text;
                        break;
                    }
                }
            }

            switch (checkedThemeName)
            {
                case "Apple": 
                    ThemeName = "ICSharpCode.WinFormsUI.Theme.ThemeMac";
                    break;
                case "Windows":
                    ThemeName = "ICSharpCode.WinFormsUI.Theme.ThemeVS2012";
                    break;
                case "Bootstrip":
                    ThemeName = "ICSharpCode.WinFormsUI.Theme.ThemeShadow";
                    break;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();

        }

        private void pnlTheme_Click(object sender, EventArgs e)
        {
            ICSharpCode.WinFormsUI.Controls.NTheme theme = (ICSharpCode.WinFormsUI.Controls.NTheme)sender;           

            switch (theme.Text)
            {
                case "Windows":
                    themeApple.Checked = false;
                    themeBootstrip.Checked = false;
                    themeWindows.Checked = true;
                    break;
                case "Apple":
                    themeWindows.Checked = false;
                    themeBootstrip.Checked = false;
                    themeApple.Checked = true;
                    break;
                case "Bootstrip":
                    themeApple.Checked = false;
                    themeWindows.Checked = false;
                    themeBootstrip.Checked = true;
                    break;
                case "More": break;
            }
          
            
        }

    }
}
